package org.gruposp2p.dnie.server.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import org.gruposp2p.dnie.model.DNIeAuthority;
import org.gruposp2p.dnie.model.DNIeDocumentToSign;
import org.gruposp2p.dnie.model.DNIeDocumentToSignOption;
import org.gruposp2p.dnie.model.DNIeDocumentType;
import org.gruposp2p.dnie.model.DNIeOptionSelectionType;
import org.gruposp2p.dnie.model.DNIeUser;
import org.gruposp2p.dnie.utils.DateUtils;


/**
 *
 * @author jj
 */
public class TestData {


    public static DNIeUser getDNIeUser (DNIeAuthority userType) {
        DNIeUser dnieUser = new DNIeUser ();
        dnieUser.setName("Murluengo");
        dnieUser.setAuthority(DNIeAuthority.ROLE_USER);
        return dnieUser;
    }
/*
    public static SignatureDocument getSignatureDocumentPopulated() {
        SignatureDocument signatureDocument = new SignatureDocument();
        SignedInfo signedInfo = new SignedInfo();
        CanonicalizationMethod canonicalizationMethod = new CanonicalizationMethod ();
        canonicalizationMethod.algorithm = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
        SignatureMethod signatureMethod = new SignatureMethod();
        signatureMethod.algorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
        Reference reference = new Reference();
        reference.uri = "#SignedData";
        DigestMethod digestMethod = new DigestMethod();
        digestMethod.algorithm = "http://www.w3.org/2000/09/xmldsig#sha1";
        reference.digestMethod = digestMethod;
        reference.digestValue = "V8+F0pfUSvObTOh2FE76cmvnPEU=";
        Transform transform = new Transform();
        transform.algorithm ="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
        List<Transform> transforms = new ArrayList<Transform>();
        transforms.add(transform);
        reference.transforms = transforms;
        KeyInfo keyInfo = new KeyInfo();
        X509Data x509Data = new X509Data();
        x509Data.X509Certificate= "certiticatecertiticate" +
                "certiticatecertiticatecertiticatecertiticatecertiticate";
        keyInfo.x509Data = x509Data;
        signatureDocument.keyInfo = keyInfo;
        signatureDocument.signatureValue = "Oba2KrMlCyHI9Z2Zm7oWs/qJYRKkISHeoi15aHXkzCg2EfFt9d/YxnxUEm8aVbEJk0NHQj" +
                "miefcTHQgb1gfpnx6NhIh37gnZGhrf8qfDrg3Vip53zDMoKH4kLah3VlODY2ny3dKtPHyBMNTNNShDH8nG" +
                "YDNuUGnFVhoqaklOhfQePuSsjdcLWRCXWg3MvclEo50+tWmKvz+g4U/POupOe6d7ckVlHLauu25l" +
                "UOAtuTWI1Fqa/BOTpbHcuGMe12FWkOcpC9E6EGhOKA3xlSm+ngpNVSq3ScjfYlwZfIN9Y2THAzW5" +
                "jSjxS9ybZuqLIT7HJG8Gf8TCX/tat/Wjf+S2qQ==";

        signedInfo.canonicalizationMethod =canonicalizationMethod;
        signedInfo.signatureMethod = signatureMethod;
        signedInfo.reference = reference;
        signatureDocument.signedInfo = signedInfo;
        SignatureDataWrapper signatureDataWrapper = new SignatureDataWrapper();
        signatureDataWrapper.dnieDocumentToSign = getDNIeDocumentToSign();
        signatureDocument.signatureDataWrapper = signatureDataWrapper;
        return signatureDocument;
    }
*/
  public static DNIeDocumentToSign getDNIeDocumentToSign () {
        DNIeDocumentToSign dnieDocumentToSign = new DNIeDocumentToSign ();
        dnieDocumentToSign.setContent("¿Crees que el acceso a Internet debería ser Universal?");
        //dnieDocumentToSign.setId(UUID.randomUUID().toString());
        dnieDocumentToSign.setDateCreated(DateUtils.getTodayDate());
        dnieDocumentToSign.setDateBegin(DateUtils.getTodayDate());
        dnieDocumentToSign.setDateEnd(DateUtils.getTodayDate());
        dnieDocumentToSign.setOptionSelectionType(DNIeOptionSelectionType.EXCLUSIVE);
        dnieDocumentToSign.setSignatureDataType(DNIeDocumentType.MANIFEST);
        dnieDocumentToSign.setTitle("Niskawaskas");
        dnieDocumentToSign.setUrl("gruposp2p.org");
        dnieDocumentToSign.setDNIeDocumentToSignoptionCollection(null);
        DNIeDocumentToSignOption option1 = new DNIeDocumentToSignOption();
        option1.setContent("1111111111");
        Collection<DNIeDocumentToSignOption> collection =
                new ArrayList<DNIeDocumentToSignOption>();
        collection.add(option1);
        DNIeDocumentToSignOption option2 = new DNIeDocumentToSignOption();
        option2.setContent("222222222");
        collection.add(option2);
        dnieDocumentToSign.setDNIeDocumentToSignoptionCollection(collection);
        return dnieDocumentToSign;
    }

}
